<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-course-add">
		<div class="form-group">
			<label class="col-sm-3 control-label">课程名：</label>
			<div class="col-sm-8">
				<input id="courseName" name="courseName" class="form-control" type="text" th:field="${course.courseName}" required>
				<input id="courseId" name="courseId" type="hidden" th:field="${course.courseId}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">任课老师：</label>
			<div class="col-sm-8">
				<select id="teacher" class="form-control select2-hidden-accessible" multiple="">
					<option th:each="teacher:${teachers}" th:value="${teacher.userId}" th:text="${teacher.userName}" th:selected="${teacher.flag}" th:disabled="${teacher.status == '1'}"></option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">开课班级：</label>
			<div class="col-sm-8">
				<select id="class" class="form-control select2-hidden-accessible" multiple="">
					<option th:each="class:${classes}" th:value="${class.deptId}" th:text="${class.deptName}" th:selected="${class.flag}" th:disabled="${class.status == '1'}"></option>
				</select>
			</div>
		</div>

	</form>
</div>
<div th:include="include::footer"></div>


<script type="text/javascript">
	var prefix = ctx + "system/course"

	$("#form-course-add").validate({
		rules:{
			xxxx:{
				required:true,
			},
		},
		focusCleanup: true
	});


	function submitHandler() {
		if ($.validate.form()) {
			var data=$("#form-course-add").serializeArray();
			var teacherId=$.form.selectSelects("teacher");
			var classId=$.form.selectSelects("class");
			data.push({"name": "teacherIds", "value": teacherId});
			data.push({"name": "classIds", "value": classId});
			$.operate.save(prefix + "/edit",data);
		}
	}

</script>
</body>
</html>
